#Script to simulate Quiz averages and Classparticiaption scores
#To use ewith Midterm in prediction final exam scores

#Set a path and read in the MidtermFinal data
path="C:/Users/Robin/Dropbox/SLAW/2ePowerPoint/ClassData/"
MidtermFinal <- read.csv(paste(path,"MidtermFinal.csv",sep=""))

#Pull out the Midterm scores and get the sample size
Midterm=MidtermFinal$Midterm
n=length(Midterm)

#Run the block of code below for each new simulation
####################################

#Generate new final exam scores
Final=20+1.5*Midterm+rnorm(n,0,10)
Final=round(Final,0)
#generate Quiz averages related to Midterm
Quiz=0.5*Midterm+rnorm(n,0,1)
Quiz=round(Quiz,1)
#Generate random Class particiaption scores
Class=sample(1:31,n,replace=TRUE)

#Fit a model to predict Final exam scores
newmodel=lm(Final~Midterm+Quiz+Class)
summary(newmodel)

#######################################